package pers.gxm.factorymethod.idcard;

import pers.gxm.factorymethod.framework.Factory;
import pers.gxm.factorymethod.framework.Product;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class IDCardFactory extends Factory {
    public static void main(String[] args) {
        IDCardFactory idCardFactory = new IDCardFactory();
        Product red = idCardFactory.create(1, "小红");

        Product light = idCardFactory.create(2, "小明");

        Product gang = idCardFactory.create(3, "小岗");


        Product song = idCardFactory.create(4, "小歌");
        red.use();
        light.use();
        Map<Integer, String> ownerMap = idCardFactory.getOwnerMap();
        System.out.println("ownerMap = " + ownerMap);



    }
    private Map<Integer,String> ownerMap = new HashMap<>();

    @Override
    public Product createProduct(int number,String owner) {
        return new IDCard(number,owner);
    }

    @Override
    public void registerProduct(Product product) {
        IDCard idCard = (IDCard) product;
       ownerMap.put(idCard.getNumber(), idCard.getOwner());
    }

    public Map<Integer,String> getOwnerMap(){
        return ownerMap;
    }
}
